<?php
class Imagetitle extends AppModel {
	var $name = 'Imagetitle';	
	var $belongsTo = array('Category'=> array(
			'className' => 'Category',
			'foreignKey' => 'category_id'			
		)); 
	
	var $hasMany = array(
		'ProductImage' => array(
			'className' => 'ProductImage',
			'foreignKey' => 'imagetitle_id'			
		)
	);
	var $validate = array(
		'image_title' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Image title cannot be left empty',
			)
		)
	);
	function total_imagetitles($id = null){
		$this->recursive=-1;
		return $this->find('count',array('conditions'=>array('Imagetitle.category_id'=>$id)));
	}
	
}
?>